package com.moduls.interfaceFunction.controller;

import com.moduls.interfaceFunction.model.User;
import com.moduls.interfaceFunction.core.*;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping
public class LoginController {

    AuthorService authorService= AuthorFactory.createProduct(AuthorType.Cache);
    @PostMapping("/login")
    public Result login(@RequestBody User user) {

      String token= authorService.login(user);
      return ResultGenerator.genSuccessResult(token);

    }

    @PostMapping("/logout")
    public Result logout(@RequestParam String token) {
        authorService.logout(token);
        return ResultGenerator.genSuccessResult();
    }
}
